import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthService } from '@global/layout/default/auth-service/auth-service';
import { DefaultComponent } from '@global/layout';
import { OverviewComponent } from "./overview/overview.component";
import { FcsNotOpenedComponent } from "./fcs-not-opened/fcs-not-opened.component";
import { FcsSuspendedComponent } from "./fcs-suspended/fcs-suspended.component";
import { FcsServiceStateGuard } from "./authentication/fcs-service-guard";
import { DomainListComponent } from './domain/list/domain-list.component';

const ROUTES: Routes = [
  {
    path: '',
    component: DefaultComponent,
    children: [
      {
        path: '',
        redirectTo: '/overview',
        pathMatch: 'full'
      },
      {
        path: 'state',
        redirectTo: '/overview',
        pathMatch: 'full'
      },
      {
        path: 'overview',
        component: OverviewComponent,
        canActivate: [FcsServiceStateGuard],
        data: {
          breadcrumb: '总览',
          product: 'FCS',
          hasRegion: true
        }
      },
      {
        path: 'fcs-not-opened',
        component: FcsNotOpenedComponent,
        data: {
          breadcrumb: '',
          product: 'FCS',
          hasRegion: true
        },
        canActivate: [AuthService]
      },
      {
        path: 'fcs-suspended',
        component: FcsSuspendedComponent,
        data: {
          breadcrumb: '',
          product: 'FCS',
          hasRegion: true
        },
        canActivate: [AuthService]
      },
      {
        path: 'application',
        loadChildren: './application/application.module#ApplicationModule',
        canActivate: [AuthService, FcsServiceStateGuard],
        data: {
          breadcrumb: '应用管理',
          product: 'FCS',
          hasRegion: true
        }
      },
      {
        path: 'fcs-manage',
        loadChildren: './fcs-manage/fcs-manage.module#FcsManageModule',
        canActivate: [AuthService, FcsServiceStateGuard],
        data: {
          breadcrumb: '函数管理',
          product: 'FCS',
          hasRegion: true
        }
      },
      {
        path: 'template',
        loadChildren: './template/template.module#TemplateModule',
        data: {
          breadcrumb: '函数模板'
        }
      },
      {
        path: 'domain',
        component: DomainListComponent,
        canActivate: [FcsServiceStateGuard],
        data: {
          breadcrumb: '自定义域名',
          product: 'FCS',
          hasRegion: true
        }
      },
      {
        path: 'layer',
        loadChildren: './layer/layer.module#LayerModule',
        canActivate: [FcsServiceStateGuard],
        data: {
          breadcrumb: '层',
          product: 'FCS',
          hasRegion: true
        }
      },
    ]
  },
];
@NgModule({
  imports: [RouterModule.forRoot(ROUTES, { useHash: true })],
  exports: [RouterModule],
  providers: [
    FcsServiceStateGuard
  ]
})
export class AppRoutingModule { }
